# SPDX-License-Identifier: Apache-2.0
"""
Create banner model

Revision ID: 10825786b3df
Revises: 590c513f1c74
Create Date: 2021-06-22 18:16:50.425481
"""

import sqlalchemy as sa

from alembic import op
from sqlalchemy.dialects import postgresql

revision = "10825786b3df"
down_revision = "590c513f1c74"

# Note: It is VERY important to ensure that a migration does not lock for a
#       long period of time and to ensure that each individual migration does
#       not break compatibility with the *previous* version of the code base.
#       This is because the migrations will be ran automatically as part of the
#       deployment process, but while the previous version of the code is still
#       up and running. Thus backwards incompatible changes must be broken up
#       over multiple migrations inside of multiple pull requests in order to
#       phase them in over multiple deploys.


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "banners",
        sa.Column(
            "id",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("gen_random_uuid()"),
            nullable=False,
        ),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("text", sa.Text(), nullable=False),
        sa.Column("link_url", sa.Text(), nullable=False),
        sa.Column("link_label", sa.String(), nullable=False),
        sa.Column("fa_icon", sa.String(), nullable=False),
        sa.Column("active", sa.Boolean(), nullable=False),
        sa.Column("end", sa.Date(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("banners")
    # ### end Alembic commands ###
